
package character_12;

import java.util.Arrays;
import java.util.Comparator;

/**
 *
 * @author Administrator
 */

public class Character_12 {

    /**
     * @param args the command line arguments
     */
    
    public static void main(String[] args) {
        
        String[] names = {"WangWu", "LiSi", "ZhangSan"};
        
        Arrays.sort(names, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length() -o2.length();
            }
        });
        
        Comparator<String> bylength = new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length() -o2.length();
            }
        };
        Arrays.sort(names, bylength);
        
        Comparator<String> byl = (String name1, String name2) -> name1.length() -name2.length();
        Arrays.sort(names, byl);
        
        Comparator<String> byle = (name1, name2) -> name1.length() -name2.length();
        Arrays.sort(names, byle);
        
        Arrays.sort(names, (name1, name2) -> name1.length() -name2.length());
        
        Arrays.sort(names, (name1, name2) -> StringOrder.byLength(name1, name2));
        
        Arrays.sort(names, StringOrder :: byLength);
        
        Arrays.sort(names, StringOrder :: byLexicographyIgnoreCase);//按照字典顺序排序，忽略大小写
        
        Arrays.sort(names, StringOrder :: byLexicography);//按照字典顺序排序
        
        Arrays.sort(names, String :: compareTo);//按照字典顺序排序
        
        Arrays.sort(names, String :: compareToIgnoreCase);//按照字典顺序排序，忽略大小写
        
        System.out.println(Arrays.toString(names));
        
    }

}
